<template>
  <div>
    <el-table v-loading="loading"
      :data="dataList">
      <el-table-column label="签约ID"
        width="200"
        prop="agreement_no" />
      <el-table-column label="用户ID"
        width="120"
        prop="user_id">
      </el-table-column>
      <el-table-column label="下次扣费日期"
        width="120"
        prop="execute_time">
      </el-table-column>
      <el-table-column label="下次扣费金额"
        width="120"
        prop="single_amount">
      </el-table-column>
      <el-table-column label="消息内容"
        min-width="200"
        prop="title">
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0"
      :total="total"
      :page.sync="queryParams.page"
      :limit.sync="queryParams.page_size"
      @pagination="getList" />
  </div>
</template>
<script>
import { getAgreementMessages } from '@/api/agreement/agreement'
import { formatMoney } from '@/utils'
export default {
  name: 'AgreementMessages',
  data () {
    return {
      loading: false,
      queryParams: {
        page: 1,
        page_size: 10
      },
      dataList: [],
      total: 0
    }
  },
  created () {
    this.getList()
  },
  methods: {
    getList () {
      this.loading = true
      getAgreementMessages(this.queryParams).then(res => {
        const data = res.data || {}
        this.dataList = (data.list || []).map(it => {
          it.single_amount = formatMoney(it.single_amount)
          return it
        })
        this.total = data.count
      }).finally(() => {
        this.loading = false
      })
    }
  }
}
</script>
